package com.appbee.core.client.startup.links;

import javax.inject.Inject;

import com.appbee.core.client.startup.StartupChain;
import com.appbee.core.client.startup.StartupLink;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HasWidgets.ForIsWidget;
import com.google.web.bindery.requestfactory.shared.Receiver;

public class StartupDataLoaderLink implements StartupLink
{
	private final IStartupDataLoader loader;

	@Inject
	public StartupDataLoaderLink(IStartupDataLoader loader)
	{
		this.loader = loader;
	}

	@Override
	public void start(final ForIsWidget container, final StartupChain chain)
	{
		loader.fire(new Receiver<Void>()
		{

			@Override
			public void onSuccess(Void response)
			{
				GWT.log("Startup data loaded");
				chain.start(container);
			}
		});
	}

}
